Skip to content

Audit panic paths, split config domains, and align release metadata#37

Merged
haasonsaas merged 10 commits intomainfrom
cursor/codebase-health-audit-5da4
Mar 14, 2026
Merged

Audit panic paths, split config domains, and align release metadata#37
haasonsaas merged 10 commits intomainfrom
cursor/codebase-health-audit-5da4

Conversation

@EvalOpsBot
Copy link
Contributor

@EvalOpsBot EvalOpsBot commented Mar 13, 2026

Summary

  • harden the highest-risk production parser panic paths by removing capture-group unwrap/expect usage in LLM response, diff, secret scanning, and verification parsing
  • reorganize Config into flattened Vault, GitHub, Agent, and Verification domain structs while migrating a slice of the command tree to idiomatic mod.rs modules
  • align release metadata with 0.5.26, add a release workflow guard for tag/version drift, and pin the Rust toolchain so the current dependency graph is reproducible
  • merge the latest main changes, resolve conflicts in the eval/config/verification pipeline, and preserve the diff parser fix for zero-count hunks

Testing

  • cargo test

Slack Thread

Open in Web Open in Cursor 

cursoragent and others added 6 commits March 13, 2026 21:02
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
Co-authored-by: EvalOpsBot <EvalOpsBot@users.noreply.github.com>
@haasonsaas
Copy link
Collaborator

@cursor review and resolve merge conflicts

@cursor
Copy link

cursor bot commented Mar 13, 2026

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@haasonsaas
Copy link
Collaborator

@cursor review and resolve merge conflicts

@haasonsaas haasonsaas marked this pull request as ready for review March 13, 2026 21:52
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Filter in parse_optional_capture rejects valid zero line counts
    • Removed the zero-value filter so hunk headers preserve valid 0 line counts, and added regression assertions for new and deleted file hunks.

fn parse_optional_capture(captures: &regex::Captures<'_>, group: usize) -> Option<usize> {
captures
.get(group)
.and_then(|value| value.as_str().parse::<usize>().ok())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The parse_optional_capture function incorrectly converts 0 to 1 for line counts in diff hunk headers, breaking parsing for new files, deleted files, and pure insertion/deletion hunks.
Severity: CRITICAL

Suggested Fix

Remove the .filter(|value| *value > 0) call within the parse_optional_capture function. This will allow the parser to correctly handle 0 as a valid line count in diff hunk headers, which is necessary for new files, deleted files, and pure insertion/deletion hunks.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/core/diff_parser.rs#L478

Potential issue: In `diff_parser.rs`, the `parse_optional_capture` function uses
`.filter(|value| *value > 0)` followed by `.unwrap_or(1)`. This incorrectly converts a
line count of `0` in a diff hunk header to `1`. This affects hunks for new files,
deleted files, and pure insertions/deletions. The hunk termination logic `consumed_old
>= old_lines && consumed_new >= new_lines` then fails because one of the conditions
(e.g., `consumed_old >= 1` for a new file) can never be met. This causes the parser to
read past the end of the hunk, corrupting the parsed diff output.

Did we get this right? 👍 / 👎 to inform future reviews.

@haasonsaas
Copy link
Collaborator

@cursor resolve the merge conflictss and address all feedback

@cursor
Copy link

cursor bot commented Mar 13, 2026

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Filter in parse_optional_capture rejects valid zero line counts
    • Removed the zero-value filter so hunk headers preserve valid 0 line counts, and added regression assertions for new and deleted file hunks.

Create PR

Open in Web Open in Cursor 

cursoragent and others added 3 commits March 13, 2026 22:29
- release: use python3 -c one-liners for version check (avoid heredoc that actionlint parses as YAML)
- Apply clippy uninlined_format_args fixes across codebase for lint job

Made-with: Cursor
Comment on lines 404 to 414
#[serde(default = "default_false")]
pub multi_pass_specialized: bool,

/// Enable agent loop for iterative tool-calling review (default false).
#[serde(default)]
pub agent_review: bool,

/// Maximum number of LLM round-trips in agent mode (default 10).
#[serde(default = "default_agent_max_iterations")]
pub agent_max_iterations: usize,

/// Optional total token budget for agent loop.
#[serde(default)]
pub agent_max_total_tokens: Option<usize>,

/// Which agent tools are enabled. None = all tools enabled.
#[serde(default)]
pub agent_tools_enabled: Option<Vec<String>>,
#[serde(default, flatten)]
pub agent: AgentConfig,

/// Whether to run the verification pass on review comments (default true).
#[serde(default = "default_true")]
pub verification_pass: bool,

/// Which model role to use for the verification pass (default Weak).
#[serde(default = "default_verification_model_role")]
pub verification_model_role: ModelRole,

/// Additional model roles used as verification judges.
#[serde(default = "default_verification_additional_model_roles")]
pub verification_additional_model_roles: Vec<ModelRole>,

/// How multiple verification judges should be combined.
#[serde(default = "default_verification_consensus_mode")]
pub verification_consensus_mode: VerificationConsensusMode,

/// Minimum verification score to keep a comment (0-10, default 5).
#[serde(default = "default_verification_min_score")]
pub verification_min_score: u8,

/// Maximum number of comments to send through verification (default 20).
#[serde(default = "default_verification_max_comments")]
pub verification_max_comments: usize,

/// When true, keep original comments if the verification pass fails or
/// returns an unparseable response (default false).
#[serde(default = "default_false")]
pub verification_fail_open: bool,
#[serde(default, flatten)]
pub verification: VerificationConfig,

/// Enable enhanced feedback loop with per-category/file-pattern tracking
/// and feedback-adjusted confidence scores (default false).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The Config struct uses #[serde(flatten)] on VerificationConfig, which contains enums. serde_yaml may fail to deserialize these fields, preventing config loading.
Severity: HIGH

Suggested Fix

Add a test case that deserializes a YAML string containing the flattened enum fields (verification_model_role, verification_consensus_mode) to confirm the failure. If it fails, consider removing #[serde(flatten)] and nesting VerificationConfig under a verification: key in the YAML. This would make the structure explicit and avoid the serde_yaml bug.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/config.rs#L396-L414

Potential issue: The `Config` struct uses `#[serde(flatten)]` on the
`VerificationConfig` struct, which contains enum-typed fields like `model_role` and
`consensus_mode`. Due to known issues in `serde_yaml` with deserializing enums within
flattened structs, loading a YAML configuration file containing fields like
`verification_model_role` will likely fail. This issue was introduced by refactoring the
configuration structure without adding corresponding deserialization tests for these
specific fields. A failure would prevent the application from starting or reloading its
configuration if a user has these settings in their `.diffscope.yml` file.

@haasonsaas haasonsaas merged commit e39c31a into main Mar 14, 2026
12 checks passed
@haasonsaas haasonsaas deleted the cursor/codebase-health-audit-5da4 branch March 14, 2026 17:40
haasonsaas added a commit that referenced this pull request Mar 14, 2026
Use symbol-graph related files to prioritize semantic RAG candidates before global similarity ranking, surface the graph-ranked hint in semantic context, add coverage for the ranking behavior, and mark TODO.md item #37 complete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants